/*
 * @name getSubStr
 * @description 两个字符串中匹配相同的最大子字符串
 * @params {str1: string, str2: string}
 * @example:
 *  str1 = 'http://10.11.185.29:33200/EPG/jsp/GZXMT/en/page/detailMuch.html'
 *  str2 = 'http://epg.gzgdnm.com:8888/lttest/GZXMT/en/page/special/special02.html'
 *  getSubStr(str1, str2) => /GZXMT/en/page/
 */
function getSubStr(str1,str2) {
    let shorter = str1, longer = str2, targetstr = '';

    if (str1.length > str2.length){
        shorter = str2;
        longer = str1;
    }

    let idx = 0;
    let subStr = '';
    for (let b = 0; b < shorter.length; b++){
        subStr = shorter.substring(idx, b);
        if(longer.indexOf(subStr) >= 0) {
            subStr.length > targetstr.length && (targetstr = subStr);
        } else {
            // 基于上一次，从下一个字母开始匹配
            ++idx;
            b = idx;
        }
    }
    return targetstr;
};
